home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / libg_261.zip / libg_261 / libg++ / src / gen / VHMap.hP < prev    next >
Text File  |  1992-04-14  |  2KB  |  85 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19.  
  20. #ifndef _<T><C>VHMap_h
  21. #ifdef __GNUG__
  22. #pragma interface
  23. #endif
  24. #define _<T><C>VHMap_h 1
  25.  
  26. #include "<T>.<C>.Map.h"
  27.  
  28.  
  29. class <T><C>VHMap : public <T><C>Map
  30. {
  31. protected:
  32.   <T>*           tab;
  33.   <C>*           cont;
  34.   char*          status;
  35.   unsigned int   size;
  36.  
  37. public:
  38.                 <T><C>VHMap(<C&> dflt,unsigned int sz=DEFAULT_INITIAL_CAPACITY);
  39.                 <T><C>VHMap(<T><C>VHMap& a);
  40.                 ~<T><C>VHMap();
  41.  
  42.   <C>&          operator [] (<T&> key);
  43.  
  44.   void          del(<T&> key);
  45.  
  46.   Pix           first();
  47.   void          next(Pix& i);
  48.   <T>&          key(Pix i);
  49.   <C>&          contents(Pix i);
  50.  
  51.   Pix           seek(<T&> key);
  52.   int           contains(<T&> key);
  53.  
  54.   void          clear(); 
  55.   void          resize(unsigned int newsize = 0);
  56.  
  57.   int           OK();
  58. };
  59.  
  60. inline <T><C>VHMap::~<T><C>VHMap()
  61. {
  62.   delete [] tab;
  63.   delete [] cont;
  64.   delete [] status;
  65. }
  66.  
  67. inline int <T><C>VHMap::contains(<T&> key)
  68. {
  69.   return seek(key) != 0;
  70. }
  71.  
  72. inline <T>& <T><C>VHMap::key(Pix i)
  73. {
  74.   if (i == 0) error("null Pix");
  75.   return *((<T>*)i);
  76. }
  77.  
  78. inline <C>& <T><C>VHMap::contents(Pix i)
  79. {
  80.   if (i == 0) error("null Pix");
  81.   return cont[((unsigned)(i) - (unsigned)(tab)) / sizeof(<T>)];
  82. }
  83.  
  84. #endif
  85.